<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MSDNWebcast.Controls"
    xmlns:lib="clr-namespace:Microsoft.Samples.KMoore.WPFSamples.Zap">

    <SolidColorBrush x:Key="SearchTextBox_Background" Color="White" />
    <SolidColorBrush x:Key="SearchTextBox_Foreground" Color="Black" />
    <LinearGradientBrush x:Key="SearchTextBox_Border" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFABADB3" Offset="0.05" />
        <GradientStop Color="#FFE2E3EA" Offset="0.07" />
        <GradientStop Color="#FFE3E9EF" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SearchTextBox_BorderMouseOver" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FF5C97C1" Offset="0.05" />
        <GradientStop Color="#FFB9D7EB" Offset="0.07" />
        <GradientStop Color="#FFC7E2F1" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBorder" Color="Transparent" />
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBackground" Color="Transparent" />
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBorder_MouseOver" Color="Green" />
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBackground_MouseOver" Color="Green" />
    <LinearGradientBrush x:Key="SearchTextBox_SearchIconBorder_MouseDown" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FFFFFFFF" Offset="0" />
        <GradientStop Color="#FFE5F4FC" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SearchTextBox_SearchIconBackground_MouseDown" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FFE7F5FD" Offset="0" />
        <GradientStop Color="#FFD2EDFC" Offset="0.5" />
        <GradientStop Color="#FFB6E3FD" Offset="0.51" />
        <GradientStop Color="#FF9DD5F3" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="SearchTextBox_LabelTextColor" Color="#8a959e" />

    <!--SearchTextBox -->
    <Style TargetType="{x:Type Controls:SearchTextBox}">
        <Setter Property="Background" Value="{StaticResource SearchTextBox_Background}" />
        <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_Border}" />
        <Setter Property="Foreground" Value="{StaticResource SearchTextBox_Foreground}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="LabelText" Value="Search" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="LabelTextColor" Value="{StaticResource SearchTextBox_LabelTextColor}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:SearchTextBox}">
                    <Border x:Name="Border"
                        Padding="0"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid x:Name="LayoutGrid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight}" />
                            </Grid.ColumnDefinitions>
                            <ScrollViewer Margin="2,2,0,0" x:Name="PART_ContentHost" Grid.Column="0" />
                            <Label x:Name="LabelText" Grid.Column="0"
                                   Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LabelTextColor}"
                                   Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LabelText}"
                                   Padding="4,2,0,0" FontStyle="Italic" />
                            <Border x:Name="PART_SearchIconBorder" Grid.Column="1" Margin="1" BorderThickness="1"
                                  Padding="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                                  BorderBrush="{StaticResource SearchTextBox_SearchIconBorder}"
                                  Background="{StaticResource SearchTextBox_SearchIconBackground}">
                                  <Image x:Name="SearchIcon" Stretch="None" Width="16" Height="16" HorizontalAlignment="Center"
                                         Opacity=".3" VerticalAlignment="Center" Source="..\Images\search.png" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_BorderMouseOver}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_BorderMouseOver}" />
                        </Trigger>

                        <Trigger Property="HasText" Value="True">
                            <Setter Property="Visibility" TargetName="LabelText" Value="Hidden" />
                            <Setter Property="Opacity" TargetName="SearchIcon" Value="1"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasText" Value="True" />
                                <Condition Property="SearchMode" Value="Instant" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Source" TargetName="SearchIcon" Value="..\Images\clear.png" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" SourceName="PART_SearchIconBorder" Value="True" />
                                <Condition Property="HasText" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="PART_SearchIconBorder"
                                  Value="{StaticResource SearchTextBox_SearchIconBorder_MouseOver}" />
                            <Setter Property="Background" TargetName="PART_SearchIconBorder"
                                  Value="{StaticResource SearchTextBox_SearchIconBackground_MouseOver}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" SourceName="PART_SearchIconBorder" Value="True" />
                                <Condition Property="HasText" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="PART_SearchIconBorder"
                                      Value="{StaticResource SearchTextBox_SearchIconBorder_MouseOver}" />
                            <Setter Property="Background" TargetName="PART_SearchIconBorder"
                                      Value="{StaticResource SearchTextBox_SearchIconBackground_MouseOver}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" SourceName="PART_SearchIconBorder" Value="True" />
                                <Condition Property="IsMouseLeftButtonDown" Value="True" />
                                <Condition Property="HasText" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Padding" TargetName="PART_SearchIconBorder" Value="2,0,0,0" />
                            <!--<Setter Property="BorderBrush" TargetName="PART_SearchIconBorder"
                                      Value="{StaticResource SearchTextBox_SearchIconBorder_MouseDown}" />
                            <Setter Property="Background" TargetName="PART_SearchIconBorder"
                                      Value="{StaticResource SearchTextBox_SearchIconBackground_MouseDown}" />-->
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Style: PlainView-->

    <Style x:Key="{ComponentResourceKey 
        TypeInTargetAssembly={x:Type Controls:PlainView},ResourceId=plainView}" TargetType="{x:Type ListView}" 
        BasedOn="{StaticResource {x:Type ListBox}}" >
        <Setter Property="HorizontalContentAlignment"
            Value="Center"/>
        <Setter Property="ItemContainerStyle" 
            Value="{Binding (ListView.View).ItemContainerStyle,
            RelativeSource={RelativeSource Self}}"/>
        <Setter Property="ItemTemplate" 
            Value="{Binding (ListView.View).ItemTemplate,
            RelativeSource={RelativeSource Self}}"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Width="{Binding (FrameworkElement.ActualWidth),
                         RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type Controls:PlainView},ResourceId=plainItemView}"
         TargetType="{x:Type ListViewItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Grid Margin="8,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="16" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Name="image" Width="12" Height="12" VerticalAlignment="Top" Source="Images/li_off.png" Margin="2,16"/>
                        <TextBlock Name="text" Grid.Column="1" Margin="8,8" Text="{Binding}" FontSize="18" LineHeight="28" Foreground="White" TextWrapping="Wrap"
                           VerticalAlignment="Bottom" FontStyle="Normal"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Source" Value="Images/li_on.png" TargetName="image"/>
                        </Trigger>
                        <Trigger Property="IsMouseCaptured" Value="True">
                            <Setter Property="Foreground" Value="White" TargetName="text"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!--Style: Zap-->
    <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" x:Key="pageButtonStyle">
        <Setter Property="Width" Value="30" />
        <Setter Property="Height" Value="30" />
    </Style>

    <Style TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource {x:Type RepeatButton}}" x:Key="pageRepeatButtonStyle">
        <Setter Property="Width" Value="30" />
        <Setter Property="Height" Value="30" />
        <Setter Property="Interval" Value="500" />
    </Style>

    <DataTemplate DataType="{x:Type lib:ZapCommandItem}" x:Key="DefaultZapCommandItemTemplate">
        <Button Command="{Binding}" Style="{StaticResource pageButtonStyle}" Content="{Binding Path=Number}"/>
    </DataTemplate>

    <Style TargetType="{x:Type ItemsControl}" x:Key="ZapScrollerCommandItemsControlStyle">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ItemsControl}">
                    <StackPanel Orientation="Horizontal" IsItemsHost="True"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type lib:ZapScroller}">
        <Setter Property="CommandItemTemplate" Value="{StaticResource DefaultZapCommandItemTemplate}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type lib:ZapScroller}">
                    <DockPanel>
                        <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Center" >
                            <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Commands}"
                            Style="{StaticResource ZapScrollerCommandItemsControlStyle}"
                            ItemTemplate="{TemplateBinding CommandItemTemplate}"/>
                        </StackPanel>

                        <lib:ZapDecorator x:Name="PART_ZapDecorator">
                            <lib:ZapPanel IsItemsHost="true" />
                        </lib:ZapDecorator>

                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>
